package com.bjfu.intelligentrecognizeserver.conversation;

import java.util.HashMap;
import java.util.Map;

public class ConversationManager {

    //存储所有会话
    private final Map<String,ConversationContext> activeConversations = new HashMap<>();

    //创建新的会话
    public ConversationContext createConversation(String sessionId) {
        ConversationContext context = new ConversationContext(sessionId);
        activeConversations.put(sessionId, context);
        return context;
    }

    //获取会话
    public ConversationContext getConversation(String sessionId) {
        return activeConversations.get(sessionId);
    }

    //添加对话
    public void addMessageToConversation(String sessionId, String message) {
        ConversationContext context = getConversation(sessionId);
        if(context != null) {
            context.addMessage(message);
        }
    }

    //删除会话
    public void removeConversation(String sessionId) {
        activeConversations.remove(sessionId);
    }
}
